<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false; 
    app.settings.asideDock = false;
  ">
  <!-- main -->
  <div class="col">
    <!-- main header -->
    <div class="bg-light lter b-b wrapper-md">
      <div class="row">
        <div class="col-sm-6 col-xs-12">
          <h1 class="m-n font-thin h3 text-black">角色管理</h1>
          <small class="text-muted">维护角色,角色&资源信息</small>
        </div>
      </div>
    </div>
    <!-- / main header -->
    <div class="wrapper-md">
        <!-- toaster directive -->
        <toaster-container toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
        <!-- / toaster directive -->

        <uib-tabset>
            <uib-tab index="0" heading="角色维护">
                <div class="panel panel-default" ng-controller="roleCtrl">
                    <div class="panel-body">
                        <div>
                            <form class="form-inline" role="form">
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">角色名称</span>
                                        <input type="text" class="form-control" ng-model="roleName" placeholder="角色名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">资源组</span>
                                        <ui-select ng-model="resourceGroup.selected" theme="bootstrap">
                                            <ui-select-match placeholder="搜索资源组名称......">{{$select.selected.groupCode}}</ui-select-match>
                                            <ui-select-choices refresh="queryGroup($select.search)" refresh-dalay="0" repeat="item in resourceGroupList | filter: $select.search">
                                                <div ng-bind-html="item.groupCode | highlight: $select.search"></div>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <div class="form-group" ng-if="resourceGroup.selected != null">
                                    <div class="input-group">
                                        <span class="input-group-addon">资源名称</span>
                                        <ui-select ng-model="resource.selected" theme="bootstrap">
                                            <ui-select-match placeholder="搜索资源名称......">{{$select.selected.resourceName}}</ui-select-match>
                                            <ui-select-choices refresh="queryResource($select.search)" refresh-dalay="0" repeat="item in resourceList | filter: $select.search">
                                                <div ng-bind-html="item.resourceName | highlight: $select.search"></div>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" ng-click="doQuery()"><span class="glyphicon glyphicon-search"></span>搜索</button>
                                    <button type="button" class="btn btn-info" ng-click="reSet()"><span class="glyphicon glyphicon-repeat"></span>重置</button>
                                    <button type="button" class="btn btn-success" ng-click="addItem()"><span class="glyphicon glyphicon-plus"></span>新增</button>
                                </div>
                            </form>
                        </div>
                        <div style="margin-top: 5px;">
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td>角色名称</td>
                                    <td>角色描述</td>
                                    <td>创建日期</td>
                                    <td class="col-md-2">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in pageData">
                                    <td>{{item.roleName}}</td>
                                    <td>{{item.roleDesc}}</td>
                                    <td>{{item.gmtCreate}}</td>
                                    <td>
                                        <button ng-click="editItem(item)"
                                                class="btn btn-xs"
                                                style="margin-left: 5px; background-color: #2e6da4; color: white;">
                                            <span class="glyphicon glyphicon-edit"></span>编辑</button>

                                        <button ng-click="delItem(item.id)"
                                                class="btn btn-xs pull-right"
                                                style="background-color: red; color: white;">
                                            <span class="glyphicon glyphicon-remove"></span>删除</button>
                                        <!---->
                                        <!--<button type="button" class="btn btn-xs btn-info pull-left" ng-click="editItem(item)"><span class="glyphicon glyphicon-edit"></span></button>-->
                                        <!--<button type="button" class="btn btn-xs btn-danger pull-right" ng-click="deleteItem(item.id)"><span class="glyphicon glyphicon-floppy-remove"></span></button>-->
                                    </td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <ul style="margin: 0px; float: right;" uib-pagination total-items="totalItems" ng-model="currentPage" items-per-page="pageLength" max-size="10" ng-change="pageChanged()" previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </div>
            </uib-tab>
            <uib-tab index="1" heading="角色&资源维护">
                <div class="panel panel-default" ng-controller="roleResourceCtrl">
                    <div class="panel-body">
                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">角色名称</span>
                                    <ui-select ng-model="role.selected" theme="bootstrap">
                                        <ui-select-match placeholder="搜索角色名称......">{{$select.selected.roleName}}</ui-select-match>
                                        <ui-select-choices refresh="queryRole($select.search)" refresh-dalay="0" repeat="item in roleList | filter: $select.search">
                                            <div ng-bind-html="item.roleName | highlight: $select.search"></div>
                                        </ui-select-choices>
                                    </ui-select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-addon">资源组</span>
                                    <ui-select ng-model="resourceGroup.selected" theme="bootstrap">
                                        <ui-select-match placeholder="搜索资源组名称......">{{$select.selected.groupCode}}</ui-select-match>
                                        <ui-select-choices refresh="queryGroup($select.search)" refresh-dalay="0" repeat="item in resourceGroupList | filter: $select.search">
                                            <div ng-bind-html="item.groupCode | highlight: $select.search"></div>
                                        </ui-select-choices>
                                    </ui-select>
                                </div>
                            </div>
                            <div class="form-group">
                                <button type="button" class="btn btn-info" ng-click="doQuery()"><span class="glyphicon glyphicon-search"></span>搜索</button>
                            </div>
                        </form>
                        <!-- 未绑定资源 -->
                        <div class="col-md-6" ng-if="pageUnbindData.length != 0">
                            <div><span><h3>未绑定资源列表</h3></span></div>
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td>资源组</td>
                                    <td>资源信息</td>
                                    <td>创建日期</td>
                                    <td class="col-md-2">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in pageUnbindData">
                                    <td>
                                        <div ng-repeat="groupItem in item.groupDOList">
                                            {{groupItem.groupCode + " - " + groupItem.groupDesc}}
                                        </div>
                                    </td>
                                    <td>
                                        <div>{{item.resourceName}}</div>
                                        <div>{{item.resourceDesc}}</div>
                                    </td>
                                    <td>{{item.gmtCreate}}</td>
                                    <td>
                                        <button type="button" class="btn btn-xs btn-success pull-left" ng-click="bindItem(item)"><span class="glyphicon glyphicon-log-in"></span>绑定</button>
                                    </td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <ul style="margin: 0px; float: right;" uib-pagination total-items="totalUnbindItems" ng-model="currentUnbindPage" items-per-page="pageUnbindLength" max-size="10" ng-change="pageUnbindChanged(currentUnbindPage)" previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                        <!-- 未绑定资源 -->

                        <!-- 已绑定资源 -->
                        <div class="col-md-6" ng-if="pageBindData.length != 0">
                            <div><span><h3>已绑定资源列表</h3></span></div>
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td>资源组</td>
                                    <td>资源信息</td>
                                    <td>创建日期</td>
                                    <td class="col-md-2">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in pageBindData">
                                    <td>
                                        <div ng-repeat="groupItem in item.groupDOList">
                                            {{groupItem.groupCode + " - " + groupItem.groupDesc}}
                                        </div>
                                    </td>
                                    <td>
                                        <div>{{item.resourceName}}</div>
                                        <div>{{item.resourceDesc}}</div>
                                    </td>
                                    <td>{{item.gmtCreate}}</td>
                                    <td>
                                        <button type="button" class="btn btn-xs btn-danger pull-left" ng-click="unbindItem(item)"><span class="glyphicon glyphicon-log-out"></span>解绑</button>
                                    </td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <ul style="margin: 0px; float: right;" uib-pagination total-items="totalBindItems" ng-model="currentBindPage" items-per-page="pageBindLength" max-size="10" ng-change="pageBindChanged(currentBindPage)" previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                        <!-- 已绑定资源 -->
                    </div>
                </div>
            </uib-tab>
        </uib-tabset>
    </div>
  </div>
  <!-- / main -->
</div>

<script type="text/ng-template" id="role">
    <div ng-include="'tpl/modal/role_modal.html'"></div>
</script>